<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 工厂模式|工厂函数：基于给定的结构产生相同结构的不同对象
        let data = {
            msg:"测试数据",
            arr:[1,2,3,4,5]
        }
        let data1 = {
            msg:"测试数据"
        }
        console.log(data==data1)
        // let data2 = data;
        let data2 = { ...data }
        console.log(data==data2)
        console.log(data.arr==data2.arr)

        // 在已知对象结构和默认值的情况下，可以同函数的方式完成快速对象生成
        //      工厂函数在程序运行过程用于快速构建 具有相同结构相同默认，但相互独立的数据对象
        function createData(){
            return {
                msg:"测试数据",
                arr:[1,2,3,4,5]
            }
        }
        let data3 = createData();
        let data4 = createData();
        let data5 = createData();
        let data6 = createData();

        console.log(data3,data4,data5,data6)
        console.log(data3==data4)
        console.log(data4==data5)
        console.log(data5==data6)

        function createClassInfo(){
            return {
                className:"wbs22062",
                skill:"前端"
            }
        }

        function Stu(name=""){
            this.name = name;
            this.info = createClassInfo();
        }
        let stu = new Stu("tom")
        let stu1 = new Stu("jack")

        console.log(stu,stu1)
    </script>
</head>
<body>
    
</body>
</html>